package com.siriframe.user.controller;

import com.siriframe.entity.Result;
import com.siriframe.user.convert.UserConverter;
import com.siriframe.user.entity.dto.UserDto;
import com.siriframe.user.entity.po.User;
import com.siriframe.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public Result add(@RequestBody UserDto userDto){
        User user = UserConverter.INSTANCE.convertUserDtoToUserPo(userDto);
        userService.insert(user);
        return Result.ok("新增用户成功");
    }
}